<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>YmsgIRC: common.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">YmsgIRC
   </div>
   <div id="projectbrief">Program enabling YMSG clients to use IRC</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('common_8h.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">common.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Commonly used functions and debugging.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;cstdio&gt;</code><br/>
<code>#include &lt;cstdlib&gt;</code><br/>
<code>#include &lt;string.h&gt;</code><br/>
<code>#include &lt;string&gt;</code><br/>
<code>#include &lt;algorithm&gt;</code><br/>
<code>#include &lt;vector&gt;</code><br/>
<code>#include &lt;windows.h&gt;</code><br/>
<code>#include &quot;<a class="el" href="_chat_renderer_8h.html">ChatRenderer.h</a>&quot;</code><br/>
</div><div class="textblock"><div class="dynheader">
Include dependency graph for common.h:</div>
<div class="dyncontent">
<div class="center"><img src="common_8h__incl.jpg" border="0" usemap="#common_8h" alt=""/></div>
<map name="common_8h" id="common_8h">
<area shape="rect" id="node17" href="_chat_renderer_8h.html" title="Yahoo&#45;chat text&#45;formatting functions." alt="" coords="624,80,736,107"/></map>
</div>
</div><div class="textblock"><div class="dynheader">
This graph shows which files directly or indirectly include this file:</div>
<div class="dyncontent">
<div class="center"><img src="common_8h__dep__incl.jpg" border="0" usemap="#common_8hdep" alt=""/></div>
<map name="common_8hdep" id="common_8hdep">
<area shape="rect" id="node3" href="channel_8h.html" title="A channel/chatroom implementation." alt="" coords="5,80,83,107"/><area shape="rect" id="node5" href="network_8h.html" title="Provides a base for an Instant Messaging network implementation." alt="" coords="41,155,119,181"/><area shape="rect" id="node10" href="license__disp_8h.html" title="Provides program license information." alt="" coords="159,80,264,107"/><area shape="rect" id="node12" href="main_8h.html" title="Provides main includes and initializes networking code." alt="" coords="227,155,288,181"/><area shape="rect" id="node7" href="_i_r_c_8h.html" title="Classes and functions useful for using Internet Relay Chat." alt="" coords="53,229,107,256"/></map>
</div>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ac7bef5d85e3dcd73eef56ad39ffc84a9"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac7bef5d85e3dcd73eef56ad39ffc84a9"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>WIN32_LEAN_AND_MEAN</b></td></tr>
<tr class="memitem:aae8fdf6bcc88c172ca8a75ad80f17a95"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aae8fdf6bcc88c172ca8a75ad80f17a95"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>DLLIMPORT</b>&#160;&#160;&#160;__declspec(dllimport)</td></tr>
<tr class="memitem:a28746d341ae11a6b67c48f0a3d14f5f8"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#a28746d341ae11a6b67c48f0a3d14f5f8">COMMON_DBG</a>&#160;&#160;&#160;1</td></tr>
<tr class="memdesc:a28746d341ae11a6b67c48f0a3d14f5f8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Specifies if debugging function-calls should be included in the build.  <a href="#a28746d341ae11a6b67c48f0a3d14f5f8"></a><br/></td></tr>
<tr class="memitem:a5d4214141a70284106f6be7ba189580d"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a5d4214141a70284106f6be7ba189580d"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#a5d4214141a70284106f6be7ba189580d">NIMP</a>(a, b)&#160;&#160;&#160;(a&amp;(~b))</td></tr>
<tr class="memdesc:a5d4214141a70284106f6be7ba189580d"><td class="mdescLeft">&#160;</td><td class="mdescRight">nonimplication - A but not B <br/></td></tr>
<tr class="memitem:a400b92aeb5bc6859a8e346dfe20cf5a2"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a400b92aeb5bc6859a8e346dfe20cf5a2"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#a400b92aeb5bc6859a8e346dfe20cf5a2">UNSET</a>(a, b)&#160;&#160;&#160;<a class="el" href="common_8h.html#a5d4214141a70284106f6be7ba189580d">NIMP</a>(a,b)</td></tr>
<tr class="memdesc:a400b92aeb5bc6859a8e346dfe20cf5a2"><td class="mdescLeft">&#160;</td><td class="mdescRight">NIMP alias. <br/></td></tr>
<tr class="memitem:a821f5b89a15339d2286b857caaa934aa"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#a821f5b89a15339d2286b857caaa934aa">UNSET_VAR</a>(a, b)&#160;&#160;&#160;a&amp;=~b</td></tr>
<tr class="memdesc:a821f5b89a15339d2286b857caaa934aa"><td class="mdescLeft">&#160;</td><td class="mdescRight">Nonimplicative assignment - Unset flags in A as specified in B.  <a href="#a821f5b89a15339d2286b857caaa934aa"></a><br/></td></tr>
<tr class="memitem:a75f5e798af4398e6a5b5ea92f724a78d"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a75f5e798af4398e6a5b5ea92f724a78d"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#a75f5e798af4398e6a5b5ea92f724a78d">RWORD</a>(w)&#160;&#160;&#160;MAKEWORD(HIBYTE(w),LOBYTE(w))</td></tr>
<tr class="memdesc:a75f5e798af4398e6a5b5ea92f724a78d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reverse the bytes in a WORD. <br/></td></tr>
<tr class="memitem:aad6a94b000456f9f2c41d05cb4616502"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aad6a94b000456f9f2c41d05cb4616502"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>MAKEDWORD</b>(p, q, r, s)&#160;&#160;&#160;MAKEWORD(p,q)|(MAKEWORD(r,s)&lt;&lt;16)</td></tr>
<tr class="memitem:a5de9819ced81214f033a6eabd4afebc5"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a5de9819ced81214f033a6eabd4afebc5"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#a5de9819ced81214f033a6eabd4afebc5">MEMZERO</a>(p, l)&#160;&#160;&#160;memset(p, 0, l)</td></tr>
<tr class="memdesc:a5de9819ced81214f033a6eabd4afebc5"><td class="mdescLeft">&#160;</td><td class="mdescRight">null a length of memory <br/></td></tr>
<tr class="memitem:a33f89b38f454712e93e0f2924f982fd7"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a33f89b38f454712e93e0f2924f982fd7"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#a33f89b38f454712e93e0f2924f982fd7">repstr</a>(a, b)&#160;&#160;&#160;<a class="el" href="common_8h.html#ad453462b9e36eabeac23cf521c522661">delstr</a>(&amp;a);a=<a class="el" href="common_8h.html#a70a04e56542e5944a655e88094af4b88">newstr</a>(b);</td></tr>
<tr class="memdesc:a33f89b38f454712e93e0f2924f982fd7"><td class="mdescLeft">&#160;</td><td class="mdescRight">free and set a C string pointer to a new heap-copy of a different C string <br/></td></tr>
<tr class="memitem:a142287b2552d8354d673374eb4da4232"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a142287b2552d8354d673374eb4da4232"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#a142287b2552d8354d673374eb4da4232">streq</a>(a, b)&#160;&#160;&#160;(strcmp(a,b)==0)</td></tr>
<tr class="memdesc:a142287b2552d8354d673374eb4da4232"><td class="mdescLeft">&#160;</td><td class="mdescRight">boolean comparison for C strings <br/></td></tr>
<tr class="memitem:ab65936840a5b666cc6c87399e9b80802"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab65936840a5b666cc6c87399e9b80802"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#ab65936840a5b666cc6c87399e9b80802">stoi</a>(s)&#160;&#160;&#160;atoi((s).c_str())</td></tr>
<tr class="memdesc:ab65936840a5b666cc6c87399e9b80802"><td class="mdescLeft">&#160;</td><td class="mdescRight">string object to integer <br/></td></tr>
<tr class="memitem:a8df68ce64c83e77549846e20f11c3819"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8df68ce64c83e77549846e20f11c3819"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>foreach_list</b>(x, y, z)&#160;&#160;&#160;for(list&lt;x&gt;::iterator y=z.begin();y!=z.end();y++)</td></tr>
<tr class="memitem:ad5e15f3af9e7bfb9ccf6f5bce63201f2"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad5e15f3af9e7bfb9ccf6f5bce63201f2"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>foreach_vector</b>(x, y, z)&#160;&#160;&#160;for(vector&lt;x&gt;::iterator y=z.begin();y!=z.end();y++)</td></tr>
<tr class="memitem:aa4ff4139a9b0561b29377b32814e7404"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa4ff4139a9b0561b29377b32814e7404"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>foreach_vector_const</b>(x, y, z)&#160;&#160;&#160;for(vector&lt;x&gt;::const_iterator y=z.begin();y!=z.end();y++)</td></tr>
<tr class="memitem:abbbc8adcda384f99067bc12d7632754c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abbbc8adcda384f99067bc12d7632754c"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>foreach_strchar</b>(x, y)&#160;&#160;&#160;for(int x=0;x&lt;strlen(y);x++)</td></tr>
<tr class="memitem:aa3b0c51b4ba3d5e662213967c08282ac"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa3b0c51b4ba3d5e662213967c08282ac"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>foreach_stringchar</b>(x, y)&#160;&#160;&#160;for(string::size_type x=0;x&lt;y.length();x++)</td></tr>
<tr class="memitem:a2117b58e19182dff91ad3558e650541d"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2117b58e19182dff91ad3558e650541d"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>QUOTE</b>(x)&#160;&#160;&#160;#x</td></tr>
<tr class="memitem:abded166abb65b3cd5374887038359429"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abded166abb65b3cd5374887038359429"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>QUOTE2</b>(x)&#160;&#160;&#160;QUOTE(x)</td></tr>
<tr class="memitem:aa724cbd8053477833db23c9cf4d48580"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa724cbd8053477833db23c9cf4d48580"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>dbg</b>(v)&#160;&#160;&#160;dbgtext(v)</td></tr>
<tr class="memitem:ad06acb408b723044c18a87dd57de3d8a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad06acb408b723044c18a87dd57de3d8a"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>dbg_do</b>(a)&#160;&#160;&#160;a</td></tr>
<tr class="memitem:a06194326cd267032ea184acf866a7d90"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a06194326cd267032ea184acf866a7d90"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>dbg_head</b>(v)&#160;&#160;&#160;dbghead(v,__FILE__,__LINE__)</td></tr>
<tr class="memitem:a3dcd40682776779917c77c9f712b3980"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3dcd40682776779917c77c9f712b3980"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>dbg_foot</b>(v)&#160;&#160;&#160;dbgfoot(v,__FILE__,__LINE__)</td></tr>
<tr class="memitem:acb773a853217475630b0f416123f4a15"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="acb773a853217475630b0f416123f4a15"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>dbgline</b>(v)&#160;&#160;&#160;dbgtext(v,true,__FILE__,__LINE__)</td></tr>
<tr class="memitem:aea0eae4efb7765c2bfd62a784256a30a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aea0eae4efb7765c2bfd62a784256a30a"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>dbg_code</b>(a)&#160;&#160;&#160;{ dbg_head(&quot;DBG_CODE &quot;);dbgline(#a);a;dbg_foot(&quot;DBG_CODE&quot;); }</td></tr>
<tr class="memitem:ae72365ac1e80d7f3dd04f15cd771198c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae72365ac1e80d7f3dd04f15cd771198c"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>ThrowD</b>(e)&#160;&#160;&#160;dbg(&quot;Exception Thrown: &quot; #e);throw e;</td></tr>
<tr class="memitem:afa458882735be89b6c52582f1fced5d1"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afa458882735be89b6c52582f1fced5d1"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>CatchD</b>(e)&#160;&#160;&#160;catch(e){ dbg(&quot;Exception Caught: &quot; #e);</td></tr>
<tr class="memitem:aa6c1f7400a2daa9d5cb56369e251dc86"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa6c1f7400a2daa9d5cb56369e251dc86"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>ReturnD</b>(r)&#160;&#160;&#160;{ dbgfoot(&quot;Return: &quot; #r,__FILE__,__LINE__); return r; }</td></tr>
<tr class="memitem:a6ffc60d515636a59ad436298ca718774"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6ffc60d515636a59ad436298ca718774"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>ReturnX</b>(r, s)&#160;&#160;&#160;{ dbgfoot(#s &quot; - Return: &quot; #r,__FILE__,__LINE__);return r; }</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ab4333992c89e17b3acbb3ebf4218e9ef"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab4333992c89e17b3acbb3ebf4218e9ef"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>dbghead</b> (const char *c=0, const char *file=0, int line=-1)</td></tr>
<tr class="memitem:aaf7a85303e80f4e9ec61c629edbbfe32"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aaf7a85303e80f4e9ec61c629edbbfe32"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>dbgfoot</b> (const char *c=0, const char *file=0, int line=-1)</td></tr>
<tr class="memitem:a05b7117c3a3d7fe6fa408864489eed19"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a05b7117c3a3d7fe6fa408864489eed19"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>dbgtext</b> (const char *c, bool indent=false, const char *file=0, int line=-1)</td></tr>
<tr class="memitem:ad162d30748476207a1429eb1a9d1597a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad162d30748476207a1429eb1a9d1597a"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>dbgtext</b> (const string &amp;s, bool indent=false, const char *file=0, int line=-1)</td></tr>
<tr class="memitem:a9d3c87b862ee1dece5a1c0cd0b6217f6"><td class="memTemplParams" colspan="2"><a class="anchor" id="a9d3c87b862ee1dece5a1c0cd0b6217f6"></a>
template&lt;typename T &gt; </td></tr>
<tr class="memitem:a9d3c87b862ee1dece5a1c0cd0b6217f6"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><b>dbg_vec</b> (const std::vector&lt; T &gt; &amp;v1)</td></tr>
<tr class="memitem:a6f15c1976c17c86183b725028b469d3f"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6f15c1976c17c86183b725028b469d3f"></a>
string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#a6f15c1976c17c86183b725028b469d3f">itos</a> (int i)</td></tr>
<tr class="memdesc:a6f15c1976c17c86183b725028b469d3f"><td class="mdescLeft">&#160;</td><td class="mdescRight">creates a string object from an interger <br/></td></tr>
<tr class="memitem:a2e8193e661b6202129fea2268b6c4e18"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2e8193e661b6202129fea2268b6c4e18"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#a2e8193e661b6202129fea2268b6c4e18">iLimit</a> (int val, int min, int max)</td></tr>
<tr class="memdesc:a2e8193e661b6202129fea2268b6c4e18"><td class="mdescLeft">&#160;</td><td class="mdescRight">applies lower and upper limitations to an integer value <br/></td></tr>
<tr class="memitem:a4cdb2b81b532aec2a22758e73087c2b0"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a4cdb2b81b532aec2a22758e73087c2b0"></a>
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#a4cdb2b81b532aec2a22758e73087c2b0">iCheckLimit</a> (int val, int min, int max)</td></tr>
<tr class="memdesc:a4cdb2b81b532aec2a22758e73087c2b0"><td class="mdescLeft">&#160;</td><td class="mdescRight">checks if an integer value is within (or equal to) lower and upper limitations. <br/></td></tr>
<tr class="memitem:afd28705df9dc52197199453d9ce1ccff"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#afd28705df9dc52197199453d9ce1ccff">StringTokenize</a> (const string &amp;str, vector&lt; string &gt; &amp;tokens, const string &amp;delimiters=&quot; &quot;)</td></tr>
<tr class="memdesc:afd28705df9dc52197199453d9ce1ccff"><td class="mdescLeft">&#160;</td><td class="mdescRight">Split a string into a vector of tokens using a delimiter list.  <a href="#afd28705df9dc52197199453d9ce1ccff"></a><br/></td></tr>
<tr class="memitem:a16d0eb8e482e3a673f11e49e31908933"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#a16d0eb8e482e3a673f11e49e31908933">StringExplode</a> (const string &amp;str, vector&lt; string &gt; &amp;parts, const string &amp;delimiter=&quot; &quot;)</td></tr>
<tr class="memdesc:a16d0eb8e482e3a673f11e49e31908933"><td class="mdescLeft">&#160;</td><td class="mdescRight">Split a string into a vector of parts using a boundary string.  <a href="#a16d0eb8e482e3a673f11e49e31908933"></a><br/></td></tr>
<tr class="memitem:aa6329d216396ac748cd968117b80228d"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa6329d216396ac748cd968117b80228d"></a>
string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#aa6329d216396ac748cd968117b80228d">stringtok</a> (const string &amp;str, const string &amp;delimiters=&quot; &quot;)</td></tr>
<tr class="memdesc:aa6329d216396ac748cd968117b80228d"><td class="mdescLeft">&#160;</td><td class="mdescRight">a wrapper for StringTokenize for string-objects that works similar to strtok <br/></td></tr>
<tr class="memitem:ac418e9fb1af0316a35093000a5461c2a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac418e9fb1af0316a35093000a5461c2a"></a>
bool&#160;</td><td class="memItemRight" valign="bottom"><b>stringreplace</b> (string &amp;s, const string &amp;sub, const string &amp;sub2)</td></tr>
<tr class="memitem:a10ae2d440e699d9907c243e65f3f2273"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a10ae2d440e699d9907c243e65f3f2273"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>MemReverse</b> (void *p, int l)</td></tr>
<tr class="memitem:ad86fefbfc025266ae6512fe724a079ef"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad86fefbfc025266ae6512fe724a079ef"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>puts</b> (const string &amp;)</td></tr>
<tr class="memitem:acb67eaa8c60794f4f202496335f6d68e"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="acb67eaa8c60794f4f202496335f6d68e"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>cputs</b> (const string &amp;)</td></tr>
<tr class="memitem:adde4134064df659d534826efe8773d1c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="adde4134064df659d534826efe8773d1c"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>cputs</b> (const char *)</td></tr>
<tr class="memitem:ad818a22f4939d4b234a842e643fd5680"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad818a22f4939d4b234a842e643fd5680"></a>
const char *&#160;</td><td class="memItemRight" valign="bottom"><b>str_trimleft</b> (const char *s, int n)</td></tr>
<tr class="memitem:a70a04e56542e5944a655e88094af4b88"><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#a70a04e56542e5944a655e88094af4b88">newstr</a> (const char *c, bool safe=true, int alloc=0)</td></tr>
<tr class="memdesc:a70a04e56542e5944a655e88094af4b88"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a heap copy of a string.  <a href="#a70a04e56542e5944a655e88094af4b88"></a><br/></td></tr>
<tr class="memitem:aeab1108176fe4a73f1d2c8da2c4f1873"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#aeab1108176fe4a73f1d2c8da2c4f1873">delstr</a> (const char **pc)</td></tr>
<tr class="memdesc:aeab1108176fe4a73f1d2c8da2c4f1873"><td class="mdescLeft">&#160;</td><td class="mdescRight">delete a heap string that has not been changed (assumes static length) and null the used pointer  <a href="#aeab1108176fe4a73f1d2c8da2c4f1873"></a><br/></td></tr>
<tr class="memitem:ad453462b9e36eabeac23cf521c522661"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_8h.html#ad453462b9e36eabeac23cf521c522661">delstr</a> (char **pc)</td></tr>
<tr class="memdesc:ad453462b9e36eabeac23cf521c522661"><td class="mdescLeft">&#160;</td><td class="mdescRight">delete a heap string that has not been changed (assumes static length) and null the used pointer  <a href="#ad453462b9e36eabeac23cf521c522661"></a><br/></td></tr>
<tr class="memitem:a43494b6609f9935790e394eba3ff5f53"><td class="memTemplParams" colspan="2"><a class="anchor" id="a43494b6609f9935790e394eba3ff5f53"></a>
template&lt;typename T &gt; </td></tr>
<tr class="memitem:a43494b6609f9935790e394eba3ff5f53"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><b>operator+=</b> (std::vector&lt; T &gt; &amp;v1, const std::vector&lt; T &gt; &amp;v2)</td></tr>
<tr class="memitem:a27ce3a35ea1131abd143842f14161501"><td class="memTemplParams" colspan="2"><a class="anchor" id="a27ce3a35ea1131abd143842f14161501"></a>
template&lt;typename T &gt; </td></tr>
<tr class="memitem:a27ce3a35ea1131abd143842f14161501"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><b>operator+=</b> (std::vector&lt; T &gt; &amp;v1, const T &amp;t1)</td></tr>
<tr class="memitem:a672732fc364917055c98aa946f1efe59"><td class="memTemplParams" colspan="2"><a class="anchor" id="a672732fc364917055c98aa946f1efe59"></a>
template&lt;typename T &gt; </td></tr>
<tr class="memitem:a672732fc364917055c98aa946f1efe59"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><b>operator&gt;&gt;</b> (const T &amp;t1, std::vector&lt; T &gt; &amp;v1)</td></tr>
<tr class="memitem:af16139a0c136b5fad603d7cac81d6523"><td class="memTemplParams" colspan="2"><a class="anchor" id="af16139a0c136b5fad603d7cac81d6523"></a>
template&lt;typename T &gt; </td></tr>
<tr class="memitem:af16139a0c136b5fad603d7cac81d6523"><td class="memTemplItemLeft" align="right" valign="top">std::vector&lt; T &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><b>operator+</b> (const std::vector&lt; T &gt; &amp;v1, const std::vector&lt; T &gt; &amp;v2)</td></tr>
<tr class="memitem:ae96b5f1f87759096e631b7b0042fd22b"><td class="memTemplParams" colspan="2"><a class="anchor" id="ae96b5f1f87759096e631b7b0042fd22b"></a>
template&lt;typename T &gt; </td></tr>
<tr class="memitem:ae96b5f1f87759096e631b7b0042fd22b"><td class="memTemplItemLeft" align="right" valign="top">std::vector&lt; T &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><b>operator+</b> (const std::vector&lt; T &gt; &amp;v1, const T &amp;t1)</td></tr>
<tr class="memitem:af1d28523368c0d6d9b11a643fa4ebd3a"><td class="memTemplParams" colspan="2"><a class="anchor" id="af1d28523368c0d6d9b11a643fa4ebd3a"></a>
template&lt;typename T &gt; </td></tr>
<tr class="memitem:af1d28523368c0d6d9b11a643fa4ebd3a"><td class="memTemplItemLeft" align="right" valign="top">std::vector&lt; T &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><b>operator+</b> (const T &amp;t1, const std::vector&lt; T &gt; &amp;v1)</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Commonly used functions and debugging. </p>
<p>Provides commonly-used includes; functions for manipulating strings, memory and logic, and functions for printing useful debugging textwith minimal effort. </p>
<dl class="section author"><dt>Author:</dt><dd>crashenator (crashenator -at- gmail.com) </dd></dl>
</div><hr/><h2>Macro Definition Documentation</h2>
<a class="anchor" id="a28746d341ae11a6b67c48f0a3d14f5f8"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define COMMON_DBG&#160;&#160;&#160;1</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Specifies if debugging function-calls should be included in the build. </p>
<p>A value of 0 will cause debugging macros used as functions to be null. </p>

</div>
</div>
<a class="anchor" id="a821f5b89a15339d2286b857caaa934aa"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define UNSET_VAR</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">a, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">b&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;a&amp;=~b</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Nonimplicative assignment - Unset flags in A as specified in B. </p>
<p>safely unset flags contained in A with flags specified in B where a-b and a XOR b are both unsafe 0011 NIMP 1010 = 0001 </p>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="aeab1108176fe4a73f1d2c8da2c4f1873"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool delstr </td>
          <td>(</td>
          <td class="paramtype">const char **&#160;</td>
          <td class="paramname"><em>pc</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>delete a heap string that has not been changed (assumes static length) and null the used pointer </p>
<p>Ease-of-use wrapper for delete[] and assignment in one. </p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramname">pc</td><td>pointer to a string-pointer (const char*). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns:</dt><dd>returns <code>true</code> if the process succeeded. </dd></dl>
<dl class="section see"><dt>See also:</dt><dd><a class="el" href="common_8h.html#a70a04e56542e5944a655e88094af4b88" title="Create a heap copy of a string.">newstr()</a> </dd>
<dd>
<a class="el" href="common_8h.html#ad453462b9e36eabeac23cf521c522661" title="delete a heap string that has not been changed (assumes static length) and null the used pointer...">delstr(char** pc)</a> </dd></dl>

</div>
</div>
<a class="anchor" id="ad453462b9e36eabeac23cf521c522661"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool delstr </td>
          <td>(</td>
          <td class="paramtype">char **&#160;</td>
          <td class="paramname"><em>pc</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>delete a heap string that has not been changed (assumes static length) and null the used pointer </p>
<p>Ease-of-use wrapper for delete[] and assignment in one. 2nd one because (char**)-&gt;(const char**) is invalid because of const qualifier-loss possibilities; even though the <a class="el" href="common_8h.html#aeab1108176fe4a73f1d2c8da2c4f1873" title="delete a heap string that has not been changed (assumes static length) and null the used pointer...">delstr()</a> code doesn't violate constness AFAIK; the goal is to release the char[] and null the char* in each. </p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramname">pc</td><td>pointer to a string-pointer (char*). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns:</dt><dd>returns <code>true</code> if the process succeeded. </dd></dl>
<dl class="section see"><dt>See also:</dt><dd><a class="el" href="common_8h.html#a70a04e56542e5944a655e88094af4b88" title="Create a heap copy of a string.">newstr()</a> </dd>
<dd>
<a class="el" href="common_8h.html#aeab1108176fe4a73f1d2c8da2c4f1873" title="delete a heap string that has not been changed (assumes static length) and null the used pointer...">delstr(const char** pc)</a> </dd></dl>

</div>
</div>
<a class="anchor" id="a70a04e56542e5944a655e88094af4b88"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char* newstr </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>c</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>safe</em> = <code>true</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>alloc</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Create a heap copy of a string. </p>
<p>This function is preferred for use ONLY when a function returns a temporary string (char*) that will change. The created char-array size will be [length+1] and the last char will be set to NULL. Note: if <code>c</code> is NULL and <code>safe</code> is True, the resulting empty string will obey the <code>alloc</code> parameter exclusively. Note: if <code>c</code> is NULL and <code>safe</code> is False, this function will fail. </p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramname">c</td><td>temporary string-pointer </td></tr>
    <tr><td class="paramname">safe</td><td>If the input pointer is NULL, this parameter ensures creation of a new (empty) string when true. </td></tr>
    <tr><td class="paramname">alloc</td><td>specifies a static length for the string. If this parameter is 0 and the input pointer is not NULL, the length becomes strlen(c). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns:</dt><dd>Success: a pointer to a copy of the original string on the heap. Failure: NULL</dd></dl>
<dl class="section see"><dt>See also:</dt><dd><a class="el" href="common_8h.html#ad453462b9e36eabeac23cf521c522661" title="delete a heap string that has not been changed (assumes static length) and null the used pointer...">delstr(char** pc)</a> </dd>
<dd>
<a class="el" href="common_8h.html#aeab1108176fe4a73f1d2c8da2c4f1873" title="delete a heap string that has not been changed (assumes static length) and null the used pointer...">delstr(const char** pc)</a> </dd></dl>

</div>
</div>
<a class="anchor" id="a16d0eb8e482e3a673f11e49e31908933"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void StringExplode </td>
          <td>(</td>
          <td class="paramtype">const string &amp;&#160;</td>
          <td class="paramname"><em>str</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">vector&lt; string &gt; &amp;&#160;</td>
          <td class="paramname"><em>parts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const string &amp;&#160;</td>
          <td class="paramname"><em>delimiter</em> = <code>&quot;&#160;&quot;</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Split a string into a vector of parts using a boundary string. </p>
<p>This function produces a vector of substrings that were followed by a boundary-string (delimiter). It should be noted that because of that process, this function ignores a leading delimiter and any trailing substring. This function works similarly (aside from the above) to PHP's explode() function. This function is also different from StringTokenize as splits where a string occurs rather than single characters.</p>
<p>The implementation for this function was influenced by understanding <a class="el" href="common_8h.html#afd28705df9dc52197199453d9ce1ccff" title="Split a string into a vector of tokens using a delimiter list.">StringTokenize()</a> (different author)</p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">str</td><td>string to be split </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">parts</td><td>reference to a vector that substrings will be added to. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">delimiter</td><td>a boundary string that marks where the input should be split at. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns:</dt><dd>none <div class="fragment"><div class="line">vector&lt;string&gt; tokens;</div>
<div class="line"><span class="keywordtype">string</span> str=<span class="stringliteral">&quot;|SPLIT|ab|c|SPLIT|de|SPLIT|zz&quot;</span>;</div>
<div class="line"><span class="keywordtype">string</span> delims=<span class="stringliteral">&quot;|SPLIT|&quot;</span>;</div>
<div class="line">StringTokenize(str,tokens,delims);</div>
<div class="line"><span class="comment">//tokens now contains: &quot;ab|c&quot;,&quot;de&quot;</span></div>
</div><!-- fragment --> </dd></dl>
<dl class="section see"><dt>See also:</dt><dd><a class="el" href="common_8h.html#afd28705df9dc52197199453d9ce1ccff" title="Split a string into a vector of tokens using a delimiter list.">StringTokenize()</a> </dd></dl>
<dl class="section author"><dt>Author:</dt><dd>crashenator (crashenator -at- gmail.com) </dd></dl>

</div>
</div>
<a class="anchor" id="afd28705df9dc52197199453d9ce1ccff"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void StringTokenize </td>
          <td>(</td>
          <td class="paramtype">const string &amp;&#160;</td>
          <td class="paramname"><em>str</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">vector&lt; string &gt; &amp;&#160;</td>
          <td class="paramname"><em>tokens</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const string &amp;&#160;</td>
          <td class="paramname"><em>delimiters</em> = <code>&quot;&#160;&quot;</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Split a string into a vector of tokens using a delimiter list. </p>
<p>This function produces a vector of substrings that were followed by a delimeter. It should be noted that because of that process, this function ignores leading delimiters and any trailing substring.</p>
<p>This function was is used from: <a href="http://www.digitalpeer.com/id/simple">http://www.digitalpeer.com/id/simple</a> (see Author below). It was used as an example to make <a class="el" href="common_8h.html#a16d0eb8e482e3a673f11e49e31908933" title="Split a string into a vector of parts using a boundary string.">StringExplode()</a>.</p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">str</td><td>string to be tokenized </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">tokens</td><td>reference to a vector that tokens will be added to. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">delimeters</td><td>a list of characters that separate tokens in the input (defaults to space) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns:</dt><dd>none <div class="fragment"><div class="line">vector&lt;string&gt; tokens;</div>
<div class="line"><span class="keywordtype">string</span> str=<span class="stringliteral">&quot;|,|ab,c|de,zz&quot;</span>;</div>
<div class="line"><span class="keywordtype">string</span> delims=<span class="stringliteral">&quot;|,&quot;</span>;</div>
<div class="line">StringTokenize(str,tokens,delims);</div>
<div class="line"><span class="comment">//tokens now contains: &quot;ab&quot;,&quot;c&quot;,&quot;de&quot;</span></div>
</div><!-- fragment --> </dd></dl>
<dl class="section see"><dt>See also:</dt><dd><a class="el" href="common_8h.html#a16d0eb8e482e3a673f11e49e31908933" title="Split a string into a vector of parts using a boundary string.">StringExplode()</a> </dd></dl>
<dl class="section author"><dt>Author:</dt><dd>J.D. Henderson (digitalpeer -at- digitalpeer.com) </dd>
<dd>
Eric Hu? </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="common_8h.html">common.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.1 </li>
  </ul>
</div>
</body>
</html>
